﻿using AutoMapper;
using DeZhen.DataCollection.Model.DTO.CollectionTask;
using DeZhen.DataCollection.Model.DTO.CollectionTemplate;
using DeZhen.DataCollection.Model.DTO.DataSourceSettings;
using DeZhen.DataCollection.Model.Entities;

namespace DeZhen.DataCollection.WebApi.Configurations
{
    public class AutoMapperConfigs : Profile
    {
        public AutoMapperConfigs()
        {
            #region 数据源设置
            CreateMap<DataSourceSettingsAdd, DataSourceSettings>();
            CreateMap<DataSourceSettingsEdit, DataSourceSettings>();
            CreateMap<DataSourceSettings, DataSourceSettingsDTO>()
                .ForMember(dest => dest.SourceTypeName, opt => opt.MapFrom(src => src.SourceType.ToString()));
            CreateMap<DataSourceSettings, DataSourceSettingsDropDownDTO>();
            #endregion

            #region 采集业务表设置
            CreateMap<CollectionTemplates, CollectionTemplateDropDownDTO>();
            #endregion

            #region 采集任务
            CreateMap<CollectionTaskDetail, CollectionTaskDetailDTO>()
                .ForMember(dest => dest.ExecuteDate, opt => opt.MapFrom(src => src.CreateTime));
            #endregion
        }
    }
}
